package com.meichis.yndms.room;


import io.reactivex.subscribers.ResourceSubscriber;

public abstract class DatabaseCallback<T> extends ResourceSubscriber<T> {

    //默认执行订阅，设置成true之后只执行一次
    private boolean dispose = false;

    public DatabaseCallback() {
    }


    @Override
    public void onNext(T t) {
        onSuccess(t);
        if (dispose)
            dispose();
    }

    /*
        请求过程中发生的错误
         */
    @Override
    public void onError(Throwable throwable) {

    }

    public abstract void onSuccess(T t);

    @Override
    public void onComplete() {

    }
}